package com.globallogic.training.javase.university.schedule;

import java.util.Set;

import com.globallogic.training.javase.university.curriculum.Activity;
import com.globallogic.training.javase.university.curriculum.Subject;
import com.globallogic.training.javase.university.member.Group;
import com.globallogic.training.javase.university.member.Instructor;

/**
 * Schedule item contains references to particular activity, room and day of
 * week and time slot.
 * 
 * @author Artem.Zeltinsh
 */
public class ScheduledActivity {

	private Activity activity;

	private Auditorium auditorium;

	private DayOfWeek dayOfWeek;

	private TimeSlot timeSlot;

	public Activity getActivity() {
		return activity;
	}

	public void setActivity(Activity activity) {
		this.activity = activity;
	}

	public Auditorium getAuditorium() {
		return auditorium;
	}

	public void setAuditorium(Auditorium auditorium) {
		this.auditorium = auditorium;
	}

	public TimeSlot getTimeSlot() {
		return timeSlot;
	}

	public void setTimeSlot(TimeSlot timeSlot) {
		this.timeSlot = timeSlot;
	}
	
	public String getActivityId() {
		return activity != null ? activity.getId() : null;
	}
	
	public Instructor getInstructor() {
		return activity != null ? activity.getInstructor() : null;
	}
	
	public String getTopic() {
		return activity != null ? activity.getTopic() : null;
	}

	@Override
	public String toString() {
		return activity + " " + auditorium + " " + dayOfWeek + " " + timeSlot;
	}

	public DayOfWeek getDayOfWeek() {
		return dayOfWeek;
	}

	public void setDayOfWeek(DayOfWeek dayOfWeek) {
		this.dayOfWeek = dayOfWeek;
	}
	
	public Subject getSubject() {
		return this.activity.getSubject();
	}
	
	public Set<Group> getGroups() {
		return activity.getEnrolledGroups();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((auditorium == null) ? 0 : auditorium.hashCode());
		result = prime * result
				+ ((dayOfWeek == null) ? 0 : dayOfWeek.hashCode());
		result = prime * result
				+ ((timeSlot == null) ? 0 : timeSlot.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ScheduledActivity other = (ScheduledActivity) obj;
		if (auditorium == null) {
			if (other.auditorium != null)
				return false;
		} else if (!auditorium.equals(other.auditorium))
			return false;
		if (dayOfWeek != other.dayOfWeek)
			return false;
		if (timeSlot != other.timeSlot)
			return false;
		return true;
	}
	
	
}
